]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Animate DnD app icons at the position they were dropped
authorJonas Dreßler <verdre@v0yd.nl>
Sun, 15 Sep 2019 09:45:47 +0000 (11:45 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 18 Sep 2019 17:14:16 +0000 (17:14 +0000)
Indicate whether dropping an app icon was successful or not by using the
newly added `animateLaunchAtPos()` API of AppIcon which starts a zoom
out animation of the icon at the position the drop happened.

To get the position of the drag actor, we have to forward the arguments
passed to `acceptDrop()` and `handleDragOver()` to the internal drag
handlers of the WorkspaceThumbnails. We can use this position directly
without transforming it to stage coordinates because the actor is a
child of `Main.uiGroup` and the animation actor will also be a child of
this container.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/121

js/ui/workspace.js
js/ui/workspaceThumbnail.js

index 92f9622f2d9fc65734d8b0e2c6bcd0612c381ca5..31779283205975a3c77c6d2b5b3b513ae47d13dd 100644 (file)
@@ -2032,6 +2032,9 @@ var Workspace = class {
             metaWindow.change_workspace_by_index(workspaceIndex, false);
             return true;
         } else if (source.app && source.app.can_open_new_window()) {
+            if (source.animateLaunchAtPos)
+                source.animateLaunchAtPos(actor.x, actor.y);
+
             source.app.open_new_window(workspaceIndex);
             return true;
         } else if (!source.app && source.shellWorkspaceLaunch) {
index 91286e2b3561cc35adde85f3964845fc0fec01e0..206fbd863267e0b9ab48525799dcf98fcf1ed535 100644 (file)
@@ -561,7 +561,7 @@ var WorkspaceThumbnail = GObject.registerClass({
     }
 
     // Draggable target interface used only by ThumbnailsBox
-    handleDragOverInternal(source, time) {
+    handleDragOverInternal(source, actor, time) {
         if (source == Main.xdndHandler) {
             this.metaWorkspace.activate(time);
             return DND.DragMotionResult.CONTINUE;
@@ -580,7 +580,7 @@ var WorkspaceThumbnail = GObject.registerClass({
         return DND.DragMotionResult.CONTINUE;
     }
 
-    acceptDropInternal(source, time) {
+    acceptDropInternal(source, actor, time) {
         if (this.state > ThumbnailState.NORMAL)
             return false;
 
@@ -600,6 +600,9 @@ var WorkspaceThumbnail = GObject.registerClass({
             metaWindow.change_workspace_by_index(this.metaWorkspace.index(), false);
             return true;
         } else if (source.app && source.app.can_open_new_window()) {
+            if (source.animateLaunchAtPos)
+                source.animateLaunchAtPos(actor.x, actor.y);
+
             source.app.open_new_window(this.metaWorkspace.index());
             return true;
         } else if (!source.app && source.shellWorkspaceLaunch) {
@@ -835,7 +838,7 @@ var ThumbnailsBox = GObject.registerClass({
         }
 
         if (this._dropWorkspace != -1)
-            return this._thumbnails[this._dropWorkspace].handleDragOverInternal(source, time);
+            return this._thumbnails[this._dropWorkspace].handleDragOverInternal(source, actor, time);
         else if (this._dropPlaceholderPos != -1)
             return source.realWindow ? DND.DragMotionResult.MOVE_DROP : DND.DragMotionResult.COPY_DROP;
         else
@@ -844,7 +847,7 @@ var ThumbnailsBox = GObject.registerClass({
 
     acceptDrop(source, actor, x, y, time) {
         if (this._dropWorkspace != -1) {
-            return this._thumbnails[this._dropWorkspace].acceptDropInternal(source, time);
+            return this._thumbnails[this._dropWorkspace].acceptDropInternal(source, actor, time);
         } else if (this._dropPlaceholderPos != -1) {
             if (!source.realWindow &&
                 (!source.app || !source.app.can_open_new_window()) &&
@@ -866,6 +869,9 @@ var ThumbnailsBox = GObject.registerClass({
                     source.metaWindow.move_to_monitor(thumbMonitor);
                 source.metaWindow.change_workspace_by_index(newWorkspaceIndex, true);
             } else if (source.app && source.app.can_open_new_window()) {
+                if (source.animateLaunchAtPos)
+                    source.animateLaunchAtPos(actor.x, actor.y);
+
                 source.app.open_new_window(newWorkspaceIndex);
             } else if (!source.app && source.shellWorkspaceLaunch) {
                 // While unused in our own drag sources, shellWorkspaceLaunch allows